﻿using System;

namespace XRM.Security.DataAccess.Context
{
    public abstract class DatabaseContext : IDisposable
    {
        private IDbContext _contextDb;

        public IDbContext ContextDb
        {
            get { return _contextDb ?? ( _contextDb = new MyContext() ); }
            set { _contextDb = value; }
        }

        public void Dispose()
        {
            if ( _contextDb != null )
            {
                _contextDb.Dispose();
                _contextDb = null;
            }

            GC.SuppressFinalize(this);
        }
    }
}
